﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using BusinessLogic;

namespace ATM_System_Mock1_G2
{
    public partial class Transfer3 : System.Web.UI.Page
    {
        AccountEntites accountE = new AccountEntites();
        CustomerBL cusB = new CustomerBL();
        CardEntites cardE = new CardEntites();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(txtAmount.Text!="")
            {
                Session["Amount"] = txtAmount.Text;
            }
        }

        public void checkAmount()
        {
            cardE.CardNo = Session["CardNo"].ToString();
            if (String.IsNullOrWhiteSpace(txtAmount.Text))
            {
                lb_thongbao.Text = "* Amount is not null";
            }
            else
            {
                decimal x = cusB.checkBalance(cardE);
                decimal Amount = decimal.Parse(txtAmount.Text);
                if (0 < Amount && Amount < x)
                {

                    Response.Redirect("Transfer4.aspx");
                }
                else
                {
                    lb_thongbao.Text = " * Amount is not valid";
                }
            }
        }
        protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
        {

            checkAmount();
        }

        protected void btn_Num1_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 1;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 2;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 3;
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 4;
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 5;
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 6;
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 7;
        }

        protected void Button9_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 8;
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 9;
        }

        protected void Button13_Click(object sender, EventArgs e)
        {
            txtAmount.Text += 0;
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            txtAmount.Text = "";
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            checkAmount();
        }

    }
}